package com.zhiyou100.converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;

public class DateConverter implements Converter<String, Date>{
	private String pattern = "yyyy-MM-dd";
	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

	@Override
	public Date convert(String sdate) {
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		Date date = null;
		try{
			date = sdf.parse(sdate);
		}catch(ParseException e){
			e.printStackTrace();
		}
		return date;
	}

}
